import { createWebHistory, createRouter } from "vue-router";
/* Layout */
import Layout from "@/layout";
/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * roles: ['admin', 'common']       // 访问路由的角色权限
 * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 招聘管理
// 用人需求申请
const NeedWorkers = () => import("@/views/recruitment/needWorkers/index.vue");
// 新建用人申请
const AddNeedPerson = () =>
  import("@/views/recruitment/needWorkers/children/addNeedPerson.vue");
// 用人申请查看
const NeedPersonView = () =>
  import("@/views/recruitment/needWorkers/children/needPersonView.vue");
// 用人申请审核
const NeedPersonWork = () =>
  import("@/views/recruitment/needWorkers/children/needPersonWork.vue");
// 应聘申请表
const JobApplication = () =>
  import("@/views/recruitment/JobApplication/index.vue");
// 应聘申请表新建
const NewJobApplication = () =>
  import("@/views/recruitment/JobApplication/children/newJobApplication.vue");
// 应聘申请表查看
const JobApplicationView = () =>
  import("@/views/recruitment/JobApplication/children/jobApplicationView.vue");
import("@/views/recruitment/JobApplication/children/newJobApplication.vue");
// 应聘申请表发起面试
const GetApplication = () =>
  import("@/views/recruitment/JobApplication/children/getApplication.vue");
// 人才库
const TalentPool = () => import("@/views/recruitment/talentPool/index.vue");
// // 人才库详情
const TalentPoolView = () =>
  import("@/views/recruitment/talentPool/children/talentPoolView.vue");
// 招聘需求明细
const DemandDetails = () =>
  import("@/views/recruitment/DemandDetails/index.vue");
// 需求查看
const DemandDetailsView = () =>
  import("@/views/recruitment/DemandDetails/children/view.vue");
const DemandDetailsEditor = () =>
  import("@/views/recruitment/DemandDetails/children/EditorView.vue");

// 面试录用流程路由
// RecruitmentProcess
const RecruitmentProcess = () =>
  import("@/views/recruitment/RecruitmentProcess/index.vue");

// 初面查看
const RecruitmentProcessFirstView = () =>
  import("@/views/recruitment/RecruitmentProcess/children/FirstView.vue");
// 初面填写信息
const RecruitmentProcessFirstAdd = () =>
  import("@/views/recruitment/RecruitmentProcess/children/FirstAddView.vue");

// 员工关系
// 入职管理
const Onboarding = () =>
  import("@/views/employeeRelations/onboarding/index.vue");
// 预入职查看
const OnboardingView = () =>
  import("@/views/employeeRelations/onboarding/children/onboardingView.vue");
// 入职办理
const AddOnboarding = () =>
  import("@/views/employeeRelations/onboarding/children/addOnboarding.vue");
// 转正管理
const RegularEmployee = () =>
  import("@/views/employeeRelations/regularEmployee/index.vue");
// 转正申请单
const AddRegular = () =>
  import("@/views/employeeRelations/regularEmployee/children/addRegular.vue");
// 转正查看
const RegularView = () =>
  import("@/views/employeeRelations/regularEmployee/children/regularView.vue");
// 调动申请
const TransferManagement = () =>
  import("@/views/employeeRelations/transferManagement/index.vue");
// 新建调动申请
const AddTransfer = () =>
  import(
    "@/views/employeeRelations/transferManagement/children/addTransfer.vue"
  );
// 调动申请查看
const TransferView = () =>
  import(
    "@/views/employeeRelations/transferManagement/children/transferView.vue"
  );
// 离职管理
const SeparationManagement = () =>
  import("@/views/employeeRelations/separationManagement/index.vue");
// 新建离职申请
const AddSeparation = () =>
  import(
    "@/views/employeeRelations/separationManagement/children/addSeparation.vue"
  );
// 离职申请查看
const SeparationView = () =>
  import(
    "@/views/employeeRelations/separationManagement/children/separationView.vue"
  );
// 档案管理
const Archives = () => import("@/views/archives/index.vue");

// 档案管理查看
const ArchivesView = () => import("@/views/archives/children/ArchivesView.vue");
// 档案管理编辑
const ArchivesEdit = () => import("@/views/archives/children/ArchivesEdit.vue");

// 劳动关系管理
const laborrelationsView = () =>
  import("@/views/laborrelations/children/laborrelationsView.vue");

// 劳动关系编辑
// const laborrelationsEdit = () => import("@/views/laborrelations/children/laborrelationsEdit.vue");

// 劳动关系合同登记
const ContractRegistration = () =>
  import("@/views/laborrelations/children/ContractRegistration.vue");
//岗位信息库
const JobInformation = () => import("@/views/JobInformation/index.vue");
const JobInformationAdd = () => import("@/views/JobInformation/children/jobInformationAdd.vue");
const JobInformationView = () => import("@/views/JobInformation/children/jobInformationView.vue");
const JobInformationEdit = () => import("@/views/JobInformation/children/jobInformationEdit.vue");
const personnelTemplate = () => import("@/views/system/personnelTemplate/index.vue");
const ceshi = () => import("@/views/system/ceshi/index.vue");
// 个人工作台

// 公共路由
export const constantRoutes = [
  {
    path: "/redirect",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "/redirect/:path(.*)",
        component: () => import("@/views/redirect/index.vue"),
      },
    ],
  },
  {
    path: "/login",
    component: () => import("@/views/login"),
    hidden: true,
  },
  {
    path: "/register",
    component: () => import("@/views/register"),
    hidden: true,
  },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/views/error/404"),
    hidden: true,
  },
  {
    path: "/401",
    component: () => import("@/views/error/401"),
    hidden: true,
  },
  {
    path: "",
    component: Layout,
    redirect: "/index",
    children: [
      {
        path: "/index",
        component: () => import("@/views/index"),
        name: "Index",
        meta: { title: "首页", icon: "dashboard", affix: true },
      },
    ],
  },
  {
    path: "/employment",
    component: Layout,
    redirect: "/employment",
    children: [
      {
        path: "/employment",
        component: () => import("@/views/employment/index"),
        name: "employment",
        meta: { title: "用工风险人才库", icon: "dashboard" },
      },
    ],
  },
  {
    path: "/laborrelations",
    component: Layout,
    redirect: "/laborrelations",
    children: [
      {
        path: "/laborrelations",
        component: () => import("@/views/laborrelations/index"),
        name: "laborrelations",
        meta: { title: "劳动关系管理", icon: "dashboard" },
      },
      {
        path: "laborrelationsView",
        component: laborrelationsView,
        name: "laborrelationsView",
        meta: {
          title: "劳动关系查看", //菜单名称
          activeMenu: "/laborrelations",
        },
        hidden: true,
      },
      // ContractRegistration 合同登记
      {
        path: "ContractRegistration",
        component: ContractRegistration,
        name: "ContractRegistration",
        meta: {
          title: "合同登记", //菜单名称
          activeMenu: "/laborrelations",
        },
        hidden: true,
      },
    ],
  },
  {
    path: '/ceshi',
    component: Layout,
    redirect: "/ceshi",
  },
  // 岗位信息库
  {
    path: "/jobInformation",
    component: Layout,
    redirect: "/jobInformation",
    children: [
      {
        path: "/jobInformation",
        component: () => import("@/views/JobInformation/index"),
        name: "jobInformation",
        meta: { title: "岗位信息库", icon: "dashboard" },
      },
      {
        path: "jobInformationAdd",
        component: JobInformationAdd,
        name: "jobInformationAdd",
        meta: {
          title: "岗位信息添加", icon: "dashboard",
          activeMenu: "/jobInformation",
        },
        hidden: true,
      },
      {
        path: "jobInformationView",
        component: JobInformationView,
        name: "jobInformationView",
        meta: {
          title: "岗位信息查看", icon: "dashboard",
          activeMenu: "/jobInformation",
        },
        hidden: true,
      },
      {
        path: "jobInformationEdit",
        component: JobInformationEdit,
        name: "jobInformationEdit",
        meta: {
          title: "岗位信息编辑", icon: "dashboard",
          activeMenu: "/jobInformation",
        },
        hidden: true,
      },
    ],
  },
  {
    path: "/workBench",
    component: Layout,
    redirect: "workBench",
    hidden: false,
    alwaysShow: true,
    redirect: "noRedirect",

    children: [
      {
        path: "PersonalWorkbench",
        component: () => import("@/views/workBench/PersonalWorkbench/index"),
        name: "PersonalWorkbench",
        meta: { title: "个人工作台", icon: "dashboard" },
        hidden: false,
      },
    ],
  },

  {
    path: "/archives",
    component: Layout,
    redirect: "/archives",
    children: [
      {
        path: "/archives",
        component: () => import("@/views/archives/index"),
        name: "archives",
        meta: { title: "员工关系", icon: "dashboard" },
      },
      {
        path: "archivesView",
        component: ArchivesView,
        name: "archivesView",
        meta: {
          title: "档案管理查看", //菜单名称
          activeMenu: "/archives",
        },
        hidden: true,
      },
      // ContractRegistration 合同登记
      {
        path: "archivesEdit",
        component: ArchivesEdit,
        name: "archivesEdit",
        meta: {
          title: "档案管理编辑", //菜单名称
          activeMenu: "/archives",
        },
        hidden: true,
      },
    ],
  },
  // {
  //   path: "archives",
  //   component: Archives,
  //   name: "archives",
  //   meta: {
  //     title: "档案管理", //菜单名称
  //   },
  //   hidden: false,
  // },

  // // 档案管理查看
  // {
  //   path: "archivesView",
  //   component: ArchivesView,
  //   name: "archivesView",
  //   meta: {
  //     title: "档案管理查看", //菜单名称
  //     activeMenu: "/employeeRelations/archives",
  //   },
  //   hidden: true,
  // },
  // // 档案管理查看
  // {
  //   path: "archivesEdit",
  //   component: ArchivesEdit,
  //   name: "archivesEdit",
  //   meta: {
  //     title: "档案管理编辑", //菜单名称
  //     activeMenu: "/employeeRelations/archives",
  //   },
  //   hidden: true,
  // },
  {
    path: "/user",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    children: [
      {
        path: "profile",
        component: () => import("@/views/system/user/profile/index"),
        name: "Profile",
        meta: { title: "个人中心", icon: "user" },
      },
    ],
  },
  // 招聘管理
  {
    path: "/recruitment",
    component: Layout,
    name: "recruitment",
    hidden: false,
    alwaysShow: true,
    redirect: "noRedirect",
    meta: {
      title: "招聘管理",
      icon: "user",
    },
    children: [
      // 用人需求申请列表
      {
        path: "needWorkers",
        component: NeedWorkers,
        name: "needWorkers",
        meta: {
          title: "用人需求申请", //菜单名称
        },
        hidden: false,
      },
      // 新建用人需求申请
      {
        path: "addNeedPerson",
        component: AddNeedPerson,
        name: "addNeedPerson",
        meta: {
          title: "新建用人需求申请", //菜单名称
          activeMenu: "/recruitment/needWorkers",
        },
        hidden: true,
      },
      // 编辑用人需求申请
      {
        path: "addNeedPerson",
        component: AddNeedPerson,
        name: "editNeedPerson",
        meta: {
          title: "用人需求申请编辑", //菜单名称
          activeMenu: "/recruitment/needWorkers",
        },
        hidden: true,
      },
      // 用人需求申请查看
      {
        path: "needPersonView",
        component: NeedPersonView,
        name: "needPersonView",
        meta: {
          title: "用人需求申请草稿查看", //菜单名称
          activeMenu: "/recruitment/needWorkers",
        },
        hidden: true,
      },
      // 用人需求申请审批中查看
      {
        path: "needPersonView",
        component: NeedPersonView,
        name: "needAppPersonView",
        meta: {
          title: "用人需求申请审批中查看", //菜单名称
          activeMenu: "/recruitment/needWorkers",
        },
        hidden: true,
      },
      // 用人需求申请审批完成查看
      {
        path: "needPersonView",
        component: NeedPersonView,
        name: "needSucPersonView",
        meta: {
          title: "用人需求申请审批完成查看", //菜单名称
          activeMenu: "/recruitment/needWorkers",
        },
        hidden: true,
      },
      // 用人需求申请审批
      {
        path: "needPersonWork",
        component: NeedPersonWork,
        name: "needPersonWork",
        meta: {
          title: "用人需求申请审批", //菜单名称
          activeMenu: "/recruitment/needWorkers",
        },
        hidden: true,
      },
      {
        path: "DemandDetails",
        component: DemandDetails,
        name: "DemandDetails",
        meta: {
          title: "招聘需求明细", //菜单名称
        },
        hidden: false,
      },
      // 招聘需求查看
      {
        path: "DemandView",
        component: DemandDetailsView,
        name: "DemandView",
        meta: {
          title: "招聘需求明细查看",
          activeMenu: "/recruitment/DemandDetails",
        },
        hidden: true,
      },
      // 招聘需求编辑
      {
        path: "DemandEditor",
        component: DemandDetailsEditor,
        name: "DemandEditor",
        meta: {
          title: "招聘需求明细编辑",
          activeMenu: "/recruitment/DemandDetails",
        },
        hidden: true,
      },
      // 应聘申请表
      {
        path: "jobApplication",
        component: JobApplication,
        name: "jobApplication",
        meta: {
          title: "应聘申请表", //菜单名称
        },
        hidden: false,
      },
      // 新建用人需求申请
      {
        path: "newJobApplication",
        component: NewJobApplication,
        name: "newJobApplication",
        meta: {
          title: "新建应聘申请表", //菜单名称
          activeMenu: "/recruitment/jobApplication",
        },
        hidden: true,
      },
      // 新建用人需求查看
      {
        path: "jobApplicationView",
        component: JobApplicationView,
        name: "jobApplicationView",
        meta: {
          title: "应聘申请表查看", //菜单名称
          activeMenu: "/recruitment/jobApplication",
        },
        hidden: true,
      },
      // 新建用人需求发起面试
      {
        path: "getApplication",
        component: GetApplication,
        name: "getApplication",
        meta: {
          title: "应聘申请表发起面试", //菜单名称
          activeMenu: "/recruitment/jobApplication",
        },
        hidden: true,
      },

      {
        path: "RecruitmentProcess",
        component: RecruitmentProcess,
        name: "RecruitmentProcess",
        meta: {
          title: "面试录用流程", //菜单名称
        },
        hidden: false,
      },
      // 初面面试信息填写
      {
        path: "RecruitmentProcessFirstAdd",
        component: RecruitmentProcessFirstAdd,
        name: "RecruitmentProcessFirstAdd",
        meta: {
          title: "面试录用流程编辑",
          activeMenu: "/recruitment/RecruitmentProcess",
        },
        hidden: true,
      },
      // 初面查看
      {
        path: "RecruitmentProcessFirstView",
        component: RecruitmentProcessFirstView,
        name: "RecruitmentProcessFirstView",
        meta: {
          title: "面试录用流程查看",
          activeMenu: "/recruitment/RecruitmentProcess",
        },
        hidden: true,
      },
      // 人才库列表
      {
        path: "talentPool",
        component: TalentPool,
        name: "talentPool",
        meta: {
          title: "人才库", //菜单名称
        },
        hidden: false,
      },
      // 人才库详情
      {
        path: "talentPoolView",
        component: TalentPoolView,
        name: "talentPoolView",
        meta: {
          title: "人才库详情", //菜单名称
          activeMenu: "/recruitment/talentPool",
        },
        hidden: true,
      },
    ],
  },
  // 员工关系
  {
    path: "/employeeRelations",
    component: Layout,
    name: "employeeRelations",
    hidden: false,
    alwaysShow: true,
    redirect: "noRedirect",
    meta: {
      title: "员工关系",
      icon: "edit",
    },
    children: [
      // 入职管理列表 regular employee
      {
        path: "onboarding",
        component: Onboarding,
        name: "onboarding",
        meta: {
          title: "入职管理", //菜单名称
        },
        hidden: false,
      },
      // 入职管理预入职查看
      {
        path: "onboardingView",
        component: OnboardingView,
        name: "onboardingView",
        meta: {
          title: "入职查看", //菜单名称
          activeMenu: "/employeeRelations/onboarding",
        },
        hidden: true,
      },
      // 入职管理预入职办理
      {
        path: "addOnboarding",
        component: AddOnboarding,
        name: "addOnboarding",
        meta: {
          title: "入职办理", //菜单名称
          activeMenu: "/employeeRelations/onboarding",
        },
        hidden: true,
      },
      // 转正管理
      {
        path: "regularEmployee",
        component: RegularEmployee,
        name: "regularEmployee",
        meta: {
          title: "转正管理", //菜单名称
        },
        hidden: false,
      },
      // 转正申请单
      {
        path: "addRegular",
        component: AddRegular,
        name: "addRegular",
        meta: {
          title: "转正申请单",
          activeMenu: "/employeeRelations/regularEmployee",
        },
        hidden: true,
      },
      // 转正申请查看
      {
        path: "regularView",
        component: RegularView,
        name: "regularView",
        meta: {
          title: "转正申请查看",
          activeMenu: "/employeeRelations/regularEmployee",
        },
        hidden: true,
      },
      // 调动申请列表
      {
        path: "transferManagement",
        component: TransferManagement,
        name: "transferManagement",
        meta: {
          title: "调动申请", //菜单名称
        },
        hidden: false,
      },
      // 新建调动申请
      {
        path: "addTransfer",
        component: AddTransfer,
        name: "addTransfer",
        meta: {
          title: "填写调动申请", //菜单名称
          activeMenu: "/employeeRelations/transferManagement",
        },
        hidden: true,
      },
      // 调动申请查看
      {
        path: "transferView",
        component: TransferView,
        name: "transferView",
        meta: {
          title: "转正申请审批-查看",
          activeMenu: "/employeeRelations/transferManagement",
        },
        hidden: true,
      },
      // 离职管理列表
      {
        path: "separationManagement",
        component: SeparationManagement,
        name: "separationManagement",
        meta: {
          title: "离职管理", //菜单名称
        },
        hidden: false,
      },
      // 新建离职申请
      {
        path: "addSeparation",
        component: AddSeparation,
        name: "addSeparation",
        meta: {
          title: "填写离职申请", //菜单名称
          activeMenu: "/employeeRelations/separationManagement",
        },
        hidden: true,
      },
      // 离职申请查看
      {
        path: "separationView",
        component: SeparationView,
        name: "separationView",
        meta: {
          title: "离职申请审批-查看",
          activeMenu: "/employeeRelations/separationManagement",
        },
        hidden: true,
      },
    ],
  },

  {
    path: "/flowable",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "definition/model/",
        component: () => import("@/views/flowable/definition/model"),
        name: "Model",
        meta: { title: "流程设计", icon: "" },
      },
    ],
  },
  {
    path: "/flowable",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "task/finished/detail/index",
        component: () => import("@/views/flowable/task/finished/detail/index"),
        name: "FinishedRecord",
        meta: { title: "流程详情", icon: "" },
      },
    ],
  },
  {
    path: "/flowable",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "task/myProcess/detail/index",
        component: () => import("@/views/flowable/task/myProcess/detail/index"),
        name: "MyProcessRecord",
        meta: { title: "流程详情", icon: "" },
      },
    ],
  },
  {
    path: "/flowable",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "task/myProcess/send/index",
        component: () => import("@/views/flowable/task/myProcess/send/index"),
        name: "SendRecord",
        meta: { title: "流程发起", icon: "" },
      },
    ],
  },
  {
    path: "/flowable",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "task/todo/detail/index",
        component: () => import("@/views/flowable/task/todo/detail/index"),
        name: "TodoRecord",
        meta: { title: "流程处理", icon: "" },
      },
    ],
  },
  {
    path: "/flowable",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "task/flowForm/index",
        component: () => import("@/views/flowable/task/flowForm/index"),
        name: "FlowForm",
        meta: { title: "流程表单", icon: "" },
      },
    ],
  },
  {
    path: "/tool",
    component: Layout,
    hidden: true,
    children: [
      {
        path: "build/index",
        component: () => import("@/views/tool/build/index"),
        name: "FormBuild",
        meta: { title: "表单配置", icon: "" },
      },
    ],
  },
];

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = [
  {
    path: "/system/user-auth",
    component: Layout,
    hidden: true,
    permissions: ["system:user:edit"],
    children: [
      {
        path: "role/:userId(\\d+)",
        component: () => import("@/views/system/user/authRole"),
        name: "AuthRole",
        meta: { title: "分配角色", activeMenu: "/system/user" },
      },
    ],
  },
  {
    path: "/system/role-auth",
    component: Layout,
    hidden: true,
    permissions: ["system:role:edit"],
    children: [
      {
        path: "user/:roleId(\\d+)",
        component: () => import("@/views/system/role/authUser"),
        name: "AuthUser",
        meta: { title: "分配用户", activeMenu: "/system/role" },
      },
    ],
  },
  {
    path: "/system/dict-data",
    component: Layout,
    hidden: true,
    permissions: ["system:dict:list"],
    children: [
      {
        path: "index/:dictId(\\d+)",
        component: () => import("@/views/system/dict/data"),
        name: "Data",
        meta: { title: "字典数据", activeMenu: "/system/dict" },
      },
    ],
  },
  {
    path: "/monitor/job-log",
    component: Layout,
    hidden: true,
    permissions: ["monitor:job:list"],
    children: [
      {
        path: "index/:jobId(\\d+)",
        component: () => import("@/views/monitor/job/log"),
        name: "JobLog",
        meta: { title: "调度日志", activeMenu: "/monitor/job" },
      },
    ],
  },
  {
    path: "/tool/gen-edit",
    component: Layout,
    hidden: true,
    permissions: ["tool:gen:edit"],
    children: [
      {
        path: "index/:tableId(\\d+)",
        component: () => import("@/views/tool/gen/editTable"),
        name: "GenEdit",
        meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
      },
    ],
  },
];
const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    }
    return { top: 0 };
  },
});

export default router;
